/*
 * @Author: 刘鑫
 * @Date: 2020-11-20 18:35:40
 * @LastEditors: 刘鑫
 * @LastEditTime: 2020-11-20 18:35:47
 * @Description:
 */
import { getlist, getCount, deleteCart, check, getDetail } from '@/api/cart';
export default function useCartModel() {
  async function getCartData(): Promise<any> {
    const res = await getlist();
    console.log('res', res);
    return res.data.cartList;
  }
  async function getCartCount(): Promise<any> {
    const res = await getCount();
    console.log('res', res);
    return res.data.cartTotal.goodsCount;
  }
  async function deleteCartData(data: any): Promise<any> {
    const res = await deleteCart(data);
    console.log('res', res);
    return res;
  }
  async function checkCart(data: any): Promise<any> {
    const res = await check(data);
    console.log('res', res);
    return res.data.cartList;
  }
  async function getDetail(id: any): Promise<any> {
    const res = await getDetail(id);
    console.log('DETAILres', res);
    return res.data.info;
  }
  return {
    getCartData,
    getCartCount,
    deleteCartData,
    checkCart,
    getDetail,
  };
}
